package com.kfm.wiki.job;

import cn.hutool.core.util.IdUtil;
import com.kfm.wiki.service.EbookService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class EbookJob {

    @Autowired
    private EbookService ebookService;

    @Scheduled(cron = "0 0/1 * * * ? ")
    public void testJob(){
        MDC.put("LOG_ID", String.valueOf(IdUtil.getSnowflakeNextId()));
        log.info("更新电子书信息开始");
        long start = System.currentTimeMillis();
        ebookService.updateEbookInfo();
        log.info("更新电子书信息完成，耗时：" + (System.currentTimeMillis() - start));
    }
}
